package com.ruoyi.project.module.propertyConstraint.service;

import java.util.Date;
import java.util.List;

import com.ruoyi.common.utils.security.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.module.propertyConstraint.mapper.PropertyConstraintMapper;
import com.ruoyi.project.module.propertyConstraint.domain.PropertyConstraint;
import com.ruoyi.project.module.propertyConstraint.service.IPropertyConstraintService;
import com.ruoyi.common.support.Convert;

/**
 * 配置属性约束 服务层实现
 * 
 * @author ruoyi
 * @date 2018-11-12
 */
@Service
public class PropertyConstraintServiceImpl implements IPropertyConstraintService 
{
	@Autowired
	private PropertyConstraintMapper propertyConstraintMapper;

	/**
     * 查询配置属性约束信息
     * 
     * @param configPropertyConstraintId 配置属性约束ID
     * @return 配置属性约束信息
     */
    @Override
	public PropertyConstraint selectPropertyConstraintById(Integer configPropertyConstraintId)
	{
	    return propertyConstraintMapper.selectPropertyConstraintById(configPropertyConstraintId);
	}
	
	/**
     * 查询配置属性约束列表
     * 
     * @param propertyConstraint 配置属性约束信息
     * @return 配置属性约束集合
     */
	@Override
	public List<PropertyConstraint> selectPropertyConstraintList(PropertyConstraint propertyConstraint)
	{
	    return propertyConstraintMapper.selectPropertyConstraintList(propertyConstraint);
	}
	
    /**
     * 新增配置属性约束
     * 
     * @param propertyConstraint 配置属性约束信息
     * @return 结果
     */
	@Override
	public int insertPropertyConstraint(PropertyConstraint propertyConstraint)
	{
		String userName = ShiroUtils.getUser().getLoginName();
		propertyConstraint.setCreateBy(userName);
		propertyConstraint.setCreateTime(new Date());
		propertyConstraint.setUpdateBy(userName);
		propertyConstraint.setUpdateTime(new Date());
	    return propertyConstraintMapper.insertPropertyConstraint(propertyConstraint);
	}
	
	/**
     * 修改配置属性约束
     * 
     * @param propertyConstraint 配置属性约束信息
     * @return 结果
     */
	@Override
	public int updatePropertyConstraint(PropertyConstraint propertyConstraint)
	{
		String userName = ShiroUtils.getUser().getLoginName();
		propertyConstraint.setCreateBy(null);
		propertyConstraint.setCreateTime(null);
		propertyConstraint.setUpdateBy(userName);
		propertyConstraint.setUpdateTime(new Date());
	    return propertyConstraintMapper.updatePropertyConstraint(propertyConstraint);
	}

	/**
     * 删除配置属性约束对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deletePropertyConstraintByIds(String ids)
	{
		return propertyConstraintMapper.deletePropertyConstraintByIds(Convert.toStrArray(ids));
	}
	
}
